package com.one.common.manager.imagepreview;

import com.one.common.view.base.BaseActivity;
import com.previewlibrary.GPreviewBuilder;
import com.previewlibrary.ZoomMediaLoader;
import com.previewlibrary.enitity.IThumbViewInfo;

import java.util.ArrayList;

/**
 * Author: zhulunjun
 * Email: zhulunjun@qq.com
 * CreateDate: 2018/12/21 14:01
 * Description： 图片预览
 **/
public class DefaultPreview implements IImagePreview<IThumbViewInfo> {

    public DefaultPreview() {
        ZoomMediaLoader.getInstance().init(new ImageLoader());
    }

    @Override
    public void preview(BaseActivity context, ArrayList<IThumbViewInfo> paths, int position) {

        GPreviewBuilder.from(context)//activity实例必须
                .setData(paths)//集合
                .setCurrentIndex(position)
                .setSingleFling(false)//是否在黑屏区域点击返回
                .setDrag(false)//是否禁用图片拖拽返回
                .setType(GPreviewBuilder.IndicatorType.Number)//指示器类型
                .start();//启动
    }


    @Override
    public void preview(BaseActivity context, ArrayList<IThumbViewInfo> paths) {
        preview(context, paths, 0);
    }

    @Override
    public void preview(BaseActivity context, IThumbViewInfo path) {
        ArrayList<IThumbViewInfo> arrayList = new ArrayList<>();
        arrayList.add(path);
        preview(context, arrayList);
    }

}
